﻿using MLSMooc.BO;
using MLSMooc.Helper;
using MLSMooc.Service.Implement.Exam;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;

namespace MLSMooc.Controllers
{
    public class ExamController : Controller
    {
        ExamServiceImpl examService = ExamServiceImpl.Getinstance();
        DAO.Implement.Exam.ExamDAO examDAO = DAO.Implement.Exam.ExamDAO.Getinstance();
        
          //提交答题
          [HttpPost]
        public async Task<int> InsertExamAnswer(List<Exam_AnswerBO> data)
        {
            var res = await examService.InsertExamAnswer(data);
            return res;
        }
        //知识点视频播放一半弹出框选择题提示正确答案；
        [HttpPost]
        public async Task<string> VideoExamAnswer(List<Exam_AnswerBO> data)
        {
            var res = await examService.VideoExamAnswer(data);
            return SerializeHelper.SerializeJson(res);
        }
        //新建表弹框选择题知识点视频播放一半弹出框选择题提示正确答案；
        [HttpPost]
        public async Task<string> VideoTanKExamAnswer(List<Exam_AnswerBO> data)
        {
            var res = await examService.VideoTanKExamAnswer(data);
            return SerializeHelper.SerializeJson(res);
        }

        //获取Mooc个人测试得分列表
        [HttpPost]
        public async Task<string> GetByAIdMoocExamList(int Aid, int CId)
        {
            var res = await examService.GetByAIdMoocExamList(Aid, CId);
            return SerializeHelper.SerializeJson(res);
        }

        //获取Mooc个人测试得分详情
        [HttpPost]
        public async Task<string> GetMoocScoreInfo(int Aid, int Cid)
        {
            var res = await examService.GetMoocScoreInfo(Aid, Cid);
            return SerializeHelper.SerializeJson(res);
        }

        //根据mooc知识点id获取mooc测试题列表
        [HttpGet]
        public async Task<string> GetCourse_ExamList(int Cid)
        {
            var res = await examDAO.GetCourse_ExamList(Cid);
            return SerializeHelper.SerializeJson(res);
        }

        //删除mooc对应习题
        public async Task<int> DeleteExaminfo(int id)
        {
            var res = await examService.DeleteExaminfo(id);
            return res;
        }
        //修改Mooc对应习题
        [HttpPost]
        public async Task<int> UpdateExaminfo(ExamBO data)
        {
            var res = await examService.UpdateExaminfo(data);
            return res;
        }

        //添加mooc对应课程习题
        [HttpPost]
        public async Task<int> InsertExamitem(ExamBO data)
        {
            var res = await examService.InsertExamitem(data);
            return res;
        }

    }
}